import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ModelFieldVO, ModelFieldForm, ModelFieldQuery } from '@/api/cms/modelField/types';

/**
 * 查询CMS扩展字段列表
 * @param query
 * @returns {*}
 */

export const listModelField = (query?: ModelFieldQuery): AxiosPromise<ModelFieldVO[]> => {
  return request({
    url: '/cms/modelField/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询CMS扩展字段详细
 * @param id
 */
export function getModelField(id: string | number): AxiosPromise<{
  code: number;
  data: ModelFieldVO;
  msg: string;
}> {
  return request({
    url: '/cms/modelField/' + id,
    method: 'get'
  });
}

/**
 * 新增CMS扩展字段
 * @param data
 */
export const addModelField = (data: ModelFieldForm) => {
  return request({
    url: '/cms/modelField',
    method: 'post',
    data: data
  });
};

/**
 * 修改CMS扩展字段
 * @param data
 */
export const updateModelField = (data: ModelFieldForm) => {
  return request({
    url: '/cms/modelField',
    method: 'put',
    data: data
  });
};

/**
 * 删除CMS扩展字段
 * @param id
 */
export const delModelField = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cms/modelField/' + id,
    method: 'delete'
  });
};
